﻿<UserControl x:Class="SLExtensions.Player.PhotoPlayer"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mediaCore="clr-namespace:SLMedia.Core;assembly=SLMedia.Core"
             xmlns:mediaPic="clr-namespace:SLMedia.Picture;assembly=SLMedia.Picture"
             xmlns:mediaInt="clr-namespace:SLMedia.Core.Interactivity;assembly=SLMedia.Core"
             xmlns:videoProvider="clr-namespace:SLMedia.PlaylistProvider.MediaRSS;assembly=SLMedia.PlaylistProvider.MediaRSS"
             xmlns:slec="clr-namespace:SLExtensions.Controls;assembly=SLExtensions.Controls"
             xmlns:sleca="clr-namespace:SLExtensions.Controls.Animation;assembly=SLExtensions.Controls"
             xmlns:sled="clr-namespace:SLExtensions.Data;assembly=SLExtensions.Data"
             xmlns:sys="clr-namespace:System;assembly=mscorlib"
             xmlns:inter="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:slint="clr-namespace:SLExtensions.Interactivity;assembly=SLExtensions.Interactivity"
             Foreground="White"
             Height="Auto"
             Width="Auto"
             RenderTransformOrigin="0.5,0.5"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
             d:DesignHeight="828"
             d:DesignWidth="949">
    <UserControl.Resources>
        <mediaPic:PictureController x:Key="controller" />
        <sled:UriToImageSourceConverter x:Key="imgSourceConverter" />
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot">
        <vsm:VisualStateManager.VisualStateGroups>
            <vsm:VisualStateGroup x:Name="BuffingStates">
                <vsm:VisualState x:Name="BufferReady">
                    <Storyboard>

                    </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Buffering">
                    <Storyboard>
                    </Storyboard>
                </vsm:VisualState>
            </vsm:VisualStateGroup>
            <vsm:VisualStateGroup x:Name="DownloadStates">
                <vsm:VisualState x:Name="DownloadReady">
                    <Storyboard>
                    </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Downloading">
                    <Storyboard>
                        <DoubleAnimation Duration="00:00:00.2"
                                         Storyboard.TargetName="gridBuffering"
                                         Storyboard.TargetProperty="Opacity"
                                         To="1" />
                    </Storyboard>
                </vsm:VisualState>
            </vsm:VisualStateGroup>
            <vsm:VisualStateGroup x:Name="PlayingStates">
                <vsm:VisualStateGroup.Transitions>
                    <vsm:VisualTransition GeneratedDuration="00:00:00.2000000" />
                </vsm:VisualStateGroup.Transitions>
                <vsm:VisualState x:Name="Playing">
                    <Storyboard>


                    </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Stopped">
                    <Storyboard>

                    </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="Paused">
                    <Storyboard>
                    </Storyboard>
                </vsm:VisualState>
            </vsm:VisualStateGroup>
            <vsm:VisualStateGroup x:Name="ScreenStates">
                <vsm:VisualState x:Name="Smallscreen">
                    <Storyboard />
                </vsm:VisualState>
                <vsm:VisualState x:Name="Fullscreen">
                    <Storyboard />
                </vsm:VisualState>
            </vsm:VisualStateGroup>
        </vsm:VisualStateManager.VisualStateGroups>
        <inter:Interaction.Behaviors>
            <slint:MapState Value="{Binding IsBuffering, Source={StaticResource controller}}">
                <slint:MapStateMapping StateName="Buffering"
                                       Value="True" />
                <slint:MapStateMapping StateName="BufferReady"
                                       Value="False" />
            </slint:MapState>
            <slint:MapState Value="{Binding PlayState, Source={StaticResource controller}}">
                <slint:MapStateMapping StateName="Playing"
                                       Value="Playing" />
                <slint:MapStateMapping StateName="Paused"
                                       Value="Paused" />
                <slint:MapStateMapping StateName="Stopped"
                                       Value="Stopped" />
            </slint:MapState>
            <slint:MapState Value="{Binding IsFullScree, Source={StaticResource controller}}">
                <slint:MapStateMapping StateName="Fullscreen"
                                       Value="True" />
                <slint:MapStateMapping StateName="Smallscreen"
                                       Value="False" />
            </slint:MapState>

        </inter:Interaction.Behaviors>
        <inter:Interaction.Triggers>
            <inter:EventTrigger EventName="MouseMove">
                <slint:MouseActivityGoToState State="PlayerVisible"
                                              InactivityState="PlayerHidden"
                                              Timeout="0:0:3" />
            </inter:EventTrigger>
        </inter:Interaction.Triggers>

        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="20" />
            <RowDefinition Height="80" />
        </Grid.RowDefinitions>

        <Border x:Name="border"
                BorderThickness="1,1,1,1"
                BorderBrush="Black"
                CornerRadius="20">
            <Border.Background>
                <LinearGradientBrush StartPoint="0.498489,0.999939"
                                     EndPoint="0.498489,-5.95552e-005">
                    <GradientStop Color="#FF000000"
                                  Offset="0" />
                    <GradientStop Color="#FF000000"
                                  Offset="0.12088" />
                    <GradientStop Color="#FF303030"
                                  Offset="0.254893" />
                    <GradientStop Color="#FF606060"
                                  Offset="0.406601" />
                    <GradientStop Color="#FF8C8C8C"
                                  Offset="0.565933" />
                    <GradientStop Color="#FF000000"
                                  Offset="0.934067" />
                    <GradientStop Color="#FF000000"
                                  Offset="0.983521" />
                    <GradientStop Color="#FF999999"
                                  Offset="1" />
                </LinearGradientBrush>
            </Border.Background>
            <Grid x:Name="grid">
                <Grid.Clip>
                    <RectangleGeometry x:Name="GridClip"
                                       Rect="0,0,10000,1000" />
                </Grid.Clip>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition Height="60" />
                </Grid.RowDefinitions>

                <Border Margin="16,16,16,20"
                        x:Name="PlayerHost">
                    <Border.Background>
                        <LinearGradientBrush StartPoint="0.499724,0.999995"
                                             EndPoint="0.499724,-8.81098e-006">
                            <GradientStop Color="#FF040404"
                                          Offset="0" />
                            <GradientStop Color="#FF260E0A"
                                          Offset="0.371503" />
                            <GradientStop Color="#FF491811"
                                          Offset="0.467026" />
                            <GradientStop Color="#FF29110D"
                                          Offset="0.536311" />
                            <GradientStop Color="#FF0A0A0A"
                                          Offset="1" />
                        </LinearGradientBrush>
                    </Border.Background>

                    <Image x:Name="media"
                           Source="{Binding CurrentItem.Source, Source={StaticResource controller}, Converter={StaticResource imgSourceConverter}}"
                           mediaPic:PictureController.PictureDisplay="{StaticResource controller}" />
                </Border>
                <Canvas Margin="0,-20.128,0,-36.1279983520508"
                        Grid.Row="1"
                        Width="1064"
                        HorizontalAlignment="Center">

                    <Path Width="1064"
                          Height="109.419"
                          Stretch="Fill"
                          Fill="#FF0A0A0A"
                          Data="M1065.33,41.471981 L873.73053,41.471981 C873.73053,41.471981 653.06506,52.976009 553.60828,6.2540278 C544.73328,2.9760129 540.01727,0.0020141599 532.41034,1.1368684E-13 C524.80438,0.0020141599 520.08838,2.9760129 511.21439,6.2540278 C411.75763,52.976009 191.0912,41.471981 191.0912,41.471981 L0,41.471981 L0,109.419 L1065.33,109.419 L1065.33,41.471981 z"
                          Canvas.Left="0"
                          Canvas.Top="8.253" />
                    <Path Width="1064"
                          Height="109.419"
                          Stretch="Fill"
                          Data="M1065.33,41.471981 L873.73053,41.471981 C873.73053,41.471981 653.06421,52.976009 553.60754,6.2540278 C544.73358,2.9760129 540.01862,0.0020141599 532.41162,1.1368684E-13 C524.80365,0.0020141599 520.08765,2.9760129 511.21469,6.2540278 C411.75699,52.976009 191.09071,41.471981 191.09071,41.471981 L0,41.471981 L0,109.419 L1065.33,109.419 L1065.33,41.471981 z"
                          Canvas.Left="0"
                          Canvas.Top="8.044">
                        <Path.Fill>
                            <LinearGradientBrush StartPoint="0.499999,1.00813"
                                                 EndPoint="0.499999,0.0332842">
                                <GradientStop Color="#10000000"
                                              Offset="0" />
                                <GradientStop Color="#10040404"
                                              Offset="0.0382457" />
                                <GradientStop Color="#10090909"
                                              Offset="0.0439606" />
                                <GradientStop Color="#10090909"
                                              Offset="0.103824" />
                                <GradientStop Color="#10090909"
                                              Offset="0.25824" />
                                <GradientStop Color="#10848484"
                                              Offset="0.350339" />
                                <GradientStop Color="#10FFFFFF"
                                              Offset="0.587906" />
                                <GradientStop Color="#10848484"
                                              Offset="0.625764" />
                                <GradientStop Color="#10090909"
                                              Offset="0.87912" />
                                <GradientStop Color="#10090909"
                                              Offset="1" />
                            </LinearGradientBrush>
                        </Path.Fill>
                    </Path>
                    <Path Width="1064"
                          Height="49.391"
                          Stretch="Fill"
                          Fill="#FF000000"
                          Data="F1 M1066,651.16498 L874.40002,651.16498 C874.40002,651.16498 653.73297,660.00299 554.276,613.28003 C545.40002,610.00098 540.68402,605.69299 533.07397,605.69299 L533.08502,605.69299 C525.47498,605.69299 520.758,610.00098 511.883,613.28003 C412.42499,660.00299 191.758,651.16498 191.758,651.16498 L0.66667199,651.16498 L0.66667199,653.83197 L191.758,653.83197 C191.758,653.83197 412.42499,665.336 511.883,618.61298 C520.758,615.33502 525.47498,612.35999 533.08502,612.35999 L533.07397,612.35999 C540.68402,612.35999 545.40002,615.33502 554.276,618.61298 C653.73297,665.336 874.40002,653.83197 874.40002,653.83197 L1066,653.83197 L1066,651.16498 z"
                          Canvas.Left="0"
                          Canvas.Top="0.594" />
                    <Path Width="1064"
                          Height="44.057"
                          Stretch="Fill"
                          StrokeThickness="1.33333"
                          StrokeLineJoin="Round"
                          Stroke="#34FFFFFF"
                          Data="F1 M0.66667199,653.16498 L191.758,653.16498 C191.758,653.16498 412.42499,664.66901 511.883,617.94702 C520.758,614.66803 525.47498,611.69299 533.08502,611.69299 L533.07397,611.69299 C540.68402,611.69299 545.40002,614.66803 554.276,617.94702 C653.73297,664.66901 874.40002,653.16498 874.40002,653.16498 L1066,653.16498"
                          Canvas.Top="5.466" />
                    <Path Width="114.501"
                          Height="52.888"
                          Stretch="Fill"
                          StrokeThickness="1.33333"
                          StrokeLineJoin="Round"
                          Stroke="#34FFFFFF"
                          Data="F1 M 9683.76,9895.91L 9620.38,9865.11L 9619.21,9864.58C 9613.94,9861.93 9608.01,9860.44 9601.72,9860.44C 9595.55,9860.44 9589.72,9861.87 9584.54,9864.42C 9584.31,9864.46 9584.08,9864.51 9583.85,9864.6L 9582.78,9865.11L 9519.39,9895.91C 9515.39,9897.85 9515.39,9901 9519.39,9902.95L 9582.78,9933.75L 9583.8,9934.2C 9584.04,9934.3 9584.27,9934.36 9584.5,9934.41C 9589.7,9936.97 9595.54,9938.41 9601.72,9938.41C 9608.06,9938.41 9614.04,9936.89 9619.35,9934.2L 9620.38,9933.75L 9683.76,9902.95C 9687.76,9901 9687.76,9897.85 9683.76,9895.91 Z "
                          Fill="#FF000000"
                          Canvas.Left="474.5"
                          Canvas.Top="10.254" />

                </Canvas>
                <Canvas Margin="0,3.41,0,0"
                        Grid.Row="1"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Top"
                        Height="16">

                    <Button Width="29.366"
                            Height="28"
                            Template="{StaticResource ButtonPrevStyle}"
                            x:Name="buttonPrev"
                            Canvas.Left="-48.095"
                            Canvas.Top="-0.378">
                        <inter:Interaction.Triggers>
                            <inter:EventTrigger EventName="Click">
                                <mediaInt:MediaTriggerAction MediaController="{StaticResource controller}"
                                                             Action="Previous" />
                            </inter:EventTrigger>
                        </inter:Interaction.Triggers>
                    </Button>

                    <Button Height="28"
                            Template="{StaticResource ButtonNextStyle}"
                            Width="43"
                            x:Name="buttonNext"
                            Canvas.Top="-0.378"
                            Canvas.Left="13.488">
                        <inter:Interaction.Triggers>
                            <inter:EventTrigger EventName="Click">
                                <mediaInt:MediaTriggerAction MediaController="{StaticResource controller}"
                                                             Action="Next" />
                            </inter:EventTrigger>
                        </inter:Interaction.Triggers>
                    </Button>

                    <CheckBox Width="36"
                              Height="36"
                              Template="{StaticResource CheckBoxPlayPause}"
                              x:Name="checkboxPlayPause"
                              Canvas.Left="-18"
                              IsChecked="{Binding IsPlaying, Mode=TwoWay, Source={StaticResource controller}}"
                              Canvas.Top="-5.253" />

                </Canvas>


                <StackPanel x:Name="gridBuffering"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Top"
                            Margin="16,2,0,0"
                            Grid.Row="1"
                            d:LayoutOverrides="VerticalAlignment, Height"
                            Opacity="0"
                            Orientation="Horizontal">
                    <TextBlock Text="Téléchargement "
                               Margin="0,1,5,0"
                               HorizontalAlignment="Left"
                               FontSize="10" />
                    <Slider Height="20"
                            Style="{StaticResource SliderVolumeStyle}"
                            x:Name="sliderBuffering"
                            IsHitTestVisible="False"
                            Width="80"
                            Value="{Binding DownloadProgress, Source={StaticResource controller}}"
                            Minimum="0"
                            Maximum="1"
                            VerticalAlignment="Top" />
                </StackPanel>

                <CheckBox Content="Fullscreen popup"
                          IsChecked="{Binding Mode=TwoWay, Path=IsPopupFullscreen, Source={StaticResource controller}}"
                          x:Name="popupFullscreen"
                          HorizontalAlignment="Right"
                          Width="26"
                          Grid.Row="1"
                          Margin="0,3.077,16.1189994812012,39.9230003356934"
                          Template="{StaticResource CheckBoxTemplateFullscreenPopup}" />
                <Grid Height="Auto"
                      HorizontalAlignment="Stretch"
                      Margin="0,-20,0,-2"
                      VerticalAlignment="Bottom"
                      Width="Auto"
                      Grid.Row="1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition Width="100" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid HorizontalAlignment="Stretch"
                          x:Name="gridDescription"
                          Background="#00000000"
                          MinHeight="27"
                          MouseEnter="gridDescription_MouseEnter"
                          MouseLeave="gridDescription_MouseLeave"
                          d:LayoutOverrides="HorizontalAlignment, Height"
                          Grid.Column="2">

                        <Border Background="Black"
                                CornerRadius="10,0,0,0">
                            <TextBlock Text="{Binding Mode=TwoWay, Path=CurrentItem.Description, Source={StaticResource controller}, Converter={StaticResource htmlStripConverter}}"
                                       x:Name="description"
                                       TextWrapping="Wrap"
                                       FontSize="10"
                                       Foreground="#FFFFFFFF"
                                       Margin="5,5,20,0"
                                       HorizontalAlignment="Stretch" />
                        </Border>

                    </Grid>

                </Grid>

                <TextBlock Text="{Binding Mode=TwoWay, Path=CurrentItem.Title, Source={StaticResource controller}}"
                           x:Name="title"
                           TextWrapping="Wrap"
                           FontSize="12"
                           Margin="5,0,274,0.833"
                           VerticalAlignment="Bottom"
                           Grid.Row="1"
                           RenderTransformOrigin="0.5,0.5"
                           Height="22.167">
					<TextBlock.RenderTransform>
						<TransformGroup>
							<ScaleTransform ScaleY="1" />
							<SkewTransform />
							<RotateTransform />
							<TranslateTransform />
						</TransformGroup>
					</TextBlock.RenderTransform>
                </TextBlock>
                <Grid Height="Auto"
                      HorizontalAlignment="Stretch"
                      Margin="0,0,0,0"
                      VerticalAlignment="Stretch"
                      Width="Auto"
                      Grid.Row="1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition Width="100" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <slec:Slider Style="{StaticResource SliderTimeLineStyle}"
                                 x:Name="sliderTimeline"
                                 Maximum="{Binding Duration, Converter={StaticResource timeSpanConverter}, Source={StaticResource controller}}"
                                 MoveValue="{Binding Position, Converter={StaticResource timeSpanConverter}, Mode=TwoWay, Source={StaticResource controller}}"
                                 Foreground="#34FFFFFF"
                                 d:LayoutOverrides="Height, GridBox"
                                 Margin="72,3,52,0"
                                 Grid.ColumnSpan="1"
                                 Grid.Column="2"
                                 VerticalAlignment="Top" />

                </Grid>
            </Grid>
        </Border>
        <Border BorderThickness="1,1,1,1"
                BorderBrush="Black"
                CornerRadius="20"
                Grid.Row="2"
                x:Name="borderPlaylist">
            <Border.Background>
                <LinearGradientBrush StartPoint="1,0.5"
                                     EndPoint="0,0.5">
                    <GradientStop Color="#FF000000"
                                  Offset="0" />
                    <GradientStop Color="#FF474747"
                                  Offset="0.491" />
                    <GradientStop Color="#FF000000"
                                  Offset="1" />
                </LinearGradientBrush>

            </Border.Background>

            <ListBox Margin="5,10,10,10"
                     ItemsPanel="{StaticResource ItemsPanelTemplatePlaylist}"
                     Style="{StaticResource ListBoxStylePlaylist}"
                     x:Name="Playlist"
                     ItemTemplate="{StaticResource DataTemplatePlaylist}"
                     ItemContainerStyle="{StaticResource ListBoxItemStylePlaylist}"
                     ItemsSource="{Binding Playlist, Source={StaticResource controller}}"
                     SelectedItem="{Binding CurrentItem, Mode=TwoWay, Source={StaticResource controller}}" />
        </Border>

    </Grid>
</UserControl>
